package servlet.recipe.control;

import mysql.JdbcUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class ico_acc {
    JdbcUtil JDBC = new JdbcUtil();
    private String sql ="select * from accounts where username=?";
    private String icoUML="chushi/img/ico_accounts/default.gif";

    public String reqIcoUML(String username) {
        if (JDBC.checkNotNull(username)) {
            try (Connection conn = JDBC.connectMySQL();
                 PreparedStatement ps = conn.prepareStatement(sql)) {
                ps.setString(1, username);
                ResultSet rs = ps.executeQuery();
                if (rs.next()) {
                    icoUML=rs.getString("ico_accounts");
                }

                // 通知用户上传成功
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
        }
        return icoUML;

    }
}
